/**
 * Package: Motor.Moving
 *
 * Requires: Motor
 */

/// <summary>Gets or sets moving speed.</summary>
byte MovingSpeed;

/// <summary>Gets or sets turning speed.</summary>
byte TurningSpeed;

/// <summary>Moves a specified amount.</summary>
/// <param name="amount">The amount to move.</param>
void Moving_Move(word amount)
{
    if (!IsMotorInitialized)
        return;

    // TODO: Move
}

/// <summary>Moves ProBot backwards.</summary>
/// <param name="amount">The amount to move.</param>
void Moving_MoveBackward(word amount)
{
    Moving_Move(-amount);
}

/// <summary>Turns left.</summary>
/// <param name="degree">The degrees to turn.</param>
void Moving_TurnLeft(word degree)
{
    if (!IsMotorInitialized)
        return;

    // TODO: Turning
}

/// <summary>Turns right.</summary>
/// <param name="degree">The degrees to turn.</param>
void Moving_TurnRight(word degree)
{
    Moving_TurnLeft(-degree);
}

/// <summary>Walks an n sided, m lengthed polygon.</summary>
/// <param name="sides">The amount of sides.</param>
/// <param name="sideLength">The length of sides.</param>
void Moving_WalkNGon(int sides, word sideLength)
{
    word distances[], degrees[];
    word degree; degree = 360 / sides;

    while (sides >= 0)
    {
        distances[sides] = sideLength;
        degree[sides] = degree;

        sides--;
    }

    Moving_WalkPolygon(distances, degrees);
}

/// <summary>Walks a polygon.</summary>
/// <param name="distances">The array of lengths.</param>
/// <param name="degrees">The array of degrees.</param>
void Moving_WalkPolygon(word distances[], word degrees[])
{
    word i; i = 0;

    while (distances[i] && degrees[i])
    {
        Moving_Move(distances[i]);
        Moving_TurnLeft(degrees[i]);

        i++;
    }
}